﻿using XNAGameEngine.Input;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using XNAGameEngine;
using XNAGameEngine.GameObject;
using XNAGameEngine.Collision;
using XNAGameEngine.Utility;

namespace XNAGameEngine
{
    class AI_Party : GameObject2D
    {
        private int numOfAIPartyMembers;
                    //For this small game we set a finite number of party members

        public int NumOfAIPartyMembers { get { return numOfAIPartyMembers; } }
                    //Public property for retunring the number of party members in the
                        //AI party

        public int[] AIPartyArray;
                    //Array to hold the party members

        public AI_Party(int aipartyID) :
            base(aipartyID)
        {
            Initialize();
        }

        public override void Initialize()
        {
            base.Initialize();
        }

        public void CreateAIParty(int aipartyMembers)
        {
            numOfAIPartyMembers = aipartyMembers;
            AIPartyArray = new int[numOfAIPartyMembers];

            for (int i = 0; i < numOfAIPartyMembers; i++)
            {
                AIPartyArray[i] = GameEngine.GetService<IManagerGameObject2D>().CreateGameObject("Warrior");
            }
        }

        public override void Update(GameTime gameTime)
        {
        }

        public void Cleanup()
        {
            GameEngine.GetService<IManagerGameObject2D>().DestroyAllGameObjects();
        }

        public void SetAICharacterStats()
        {
            Warrior tempDude;

            for (int i = 0; i < numOfAIPartyMembers; i++)
            {
                tempDude = (Warrior)GameEngine.GetService<IManagerGameObject2D>().GetGameObjectById(AIPartyArray[i]);
                tempDude.normalspeed = MathToolbox.GetRandom.Next(2, 10);
                tempDude.currentspeed = tempDude.normalspeed;
                tempDude.MaxHP = 100;
                tempDude.CurrentHP = tempDude.MaxHP;
                tempDude.AttackPower = MathToolbox.GetRandom.Next(10, 15);
            }
        }
    }
}
